#include<bits/stdc++.h>
using namespace std;
#define int long long

struct node {
	int height, strength;
} app[5005];

signed main() {
	int n, s, a, b;
	cin >> n >> s >> a >> b;
	for (int i = 1; i <= n; i++) {
		cin >> app[i].height >> app[i].strength;
	}

	sort(app + 1, app + n + 1, [](node x, node y) {
		if (x.strength != y.strength)
			return x.strength < y.strength;
		else
			return x.height < y.height;
	});

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (s >= app[i].strength) {
			if (a + b >= app[i].height) {
				s -= app[i].strength;
				ans++;
			}
		} else {
			break;
		}
	}
	cout << ans;
	return 0;
}
